package com.example.myapplication;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

public class ConfigActivity extends AppCompatActivity {

    private static final String TAG = "Main2";
    private float dollar2 ;
    private float euro2;
    private float won2;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_config);

        Intent intent = getIntent();
        dollar2 = intent.getFloatExtra("dollar_key",0.0f);
        euro2 = intent.getFloatExtra("euro_key",0.0f);
        won2 = intent.getFloatExtra("won_key",0.0f);

        Log.i(TAG,"onCreate:dollar2="+dollar2);
        Log.i(TAG,"onCreate:euro2="+euro2);
        Log.i(TAG,"onCreate:won2="+won2);
    }
    public void save(View btn) {
        EditText input1 = findViewById(R.id.new_dollarrate);
        EditText input2 = findViewById(R.id.new_eurorate);
        EditText input3 = findViewById(R.id.new_wonrate);

        String s1 = input1.getText().toString();
        String s2 = input2.getText().toString();
        String s3 = input3.getText().toString();
        dollar2 = Float.parseFloat(s1);
        euro2 = Float.parseFloat(s2);
        won2 = Float.parseFloat(s3);


        Log.i(TAG,"open:save");
        Intent intent2 = new Intent(this,MainActivity2.class);
        intent2.putExtra("dollar_key",dollar2);
        intent2.putExtra("euro_key",euro2);
        intent2.putExtra("won_key",won2);

        Log.i(TAG,"open:dollar2"+dollar2);
        Log.i(TAG,"open:euro2"+euro2);
        Log.i(TAG,"open:won2"+won2);
    //    startActivity(intent2);

        Intent intent =getIntent();
        Bundle bundle = new Bundle();
        bundle.putFloat("dollar2",Float.parseFloat(s1));
        bundle.putFloat("euro2",Float.parseFloat(s2));
        bundle.putFloat("won2",Float.parseFloat(s3));
        intent.putExtras(bundle);
        setResult(6,intent);
        finish();
    }

}